import java.util.*;;
public class _12124 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int t= sc.nextInt();
        for(int i=0;i<t;i++){
            int q=sc.nextInt();
            String n = sc.next();
            int m=fuck(n);
            if(m==0){
                System.out.println("No");
            }else System.out.println("Yes");
        }
    }
    public static int fuck(String s){
        int n =s.length();
        if(n<=3){
            return 0;
        }else {
            for(int i=0;i<n-1;i++){
                String a=s.substring(i, i+2);
                int id = s.lastIndexOf(a);
                if(id>(i+1)){
                    return 1;
                }
            }
        }
        return 0;
    }
}